package com.pig4cloud.pig.village.collect.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pig.village.api.entity.CollectInfo;
import com.pig4cloud.pig.village.collect.mapper.CollectInfoMapper;
import com.pig4cloud.pig.village.collect.service.ICollectInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author limbray.li
 * @date 2021/6/19
 */
@Service
@RequiredArgsConstructor
public class CollectInfoServiceImpl extends ServiceImpl<CollectInfoMapper, CollectInfo> implements ICollectInfoService {
	@Override
	public Boolean accessReward(Long eventId) {
		LambdaUpdateWrapper<CollectInfo> update = Wrappers.lambdaUpdate();
		update.eq(CollectInfo::getEventId, eventId);
		update.set(CollectInfo::getStatus, 1);
		return super.update(update);
	}

	@Override
	public Boolean removeByEvent(Long eventId) {
		LambdaQueryWrapper<CollectInfo> query = Wrappers.lambdaQuery();
		query.eq(CollectInfo::getEventId, eventId);
		return super.remove(query);
	}
}
